{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Installing hub:\u001b[35m/\u001b[0m\u001b[35m/guardrails/\u001b[0m\u001b[95mvalid_length...\u001b[0m\n",
      "✅Successfully installed guardrails/valid_length!\n",
      "\n",
      "\n",
      "Installing hub:\u001b[35m/\u001b[0m\u001b[35m/guardrails/\u001b[0m\u001b[95mtwo_words...\u001b[0m\n",
      "✅Successfully installed guardrails/two_words!\n",
      "\n",
      "\n",
      "Installing hub:\u001b[35m/\u001b[0m\u001b[35m/guardrails/\u001b[0m\u001b[95mvalid_range...\u001b[0m\n",
      "✅Successfully installed guardrails/valid_range!\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!guardrails hub install hub://guardrails/valid_length --quiet\n",
    "!guardrails hub install hub://guardrails/two_words --quiet\n",
    "!guardrails hub install hub://guardrails/valid_range --quiet"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Generating Structured Synthetic Data\n",
    "\n",
    "!!! note\n",
    "    To download this tutorial as a Jupyter notebook, click [here](https://github.com/ShreyaR/guardrails/blob/main/docs/examples/generate_structured_data.ipynb).\n",
    "\n",
    "In this example, we'll generate structured dummy data for a `pandas` dataframe.\n",
    "\n",
    "We make the assumption that:\n",
    "\n",
    "1. We don't need any external libraries that are not already installed in the environment.\n",
    "2. We are able to execute the code in the environment.\n",
    "\n",
    "## Objective\n",
    "\n",
    "We want to generate structured synthetic data, where each column has a specific data type. All rows in the dataset must respect the column data types. Additionally, we have some more constraints we want the data to respect:\n",
    "\n",
    "1. There should be exactly 10 rows in the dataset.\n",
    "2. Each user should have a first name and a last name.\n",
    "3. The number of orders associated with each user should be between 0 and 50.\n",
    "4. Each user should have a most recent order date.\n",
    "\n",
    "## Step 1: Generating Pydantic `RAIL` Spec"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pydantic import BaseModel, Field\n",
    "from guardrails.hub import ValidLength, TwoWords, ValidRange\n",
    "from typing import List\n",
    "\n",
    "prompt = \"\"\"\n",
    "Generate a dataset of fake user orders. Each row of the dataset should be valid.\n",
    "\n",
    "${gr.complete_xml_suffix}\n",
    "\"\"\"\n",
    "\n",
    "\n",
    "class Order(BaseModel):\n",
    "    user_id: str = Field(description=\"The user's id.\")\n",
    "    user_name: str = Field(\n",
    "        description=\"The user's first name and last name\",\n",
    "        validators=[TwoWords(on_fail=\"noop\")],\n",
    "    )\n",
    "    num_orders: int = Field(\n",
    "        description=\"The number of orders the user has placed\",\n",
    "        validators=[ValidRange(0, 50, on_fail=\"noop\")],\n",
    "    )\n",
    "\n",
    "\n",
    "class Orders(BaseModel):\n",
    "    user_orders: List[Order] = Field(\n",
    "        description=\"Generate a list of user, and how many orders they have placed in the past.\",\n",
    "        validators=[ValidLength(10, 10, on_fail=\"noop\")],\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Step 2: Create a `Guard` object with the RAIL Spec\n",
    "\n",
    "We create a `gd.Guard` object that will check, validate and correct the generated code. This object:\n",
    "\n",
    "1. Enforces the quality criteria specified in the RAIL spec (i.e. bug free code).\n",
    "2. Takes corrective action when the quality criteria are not met (i.e. reasking the LLM).\n",
    "3. Compiles the schema and type info from the RAIL spec and adds it to the prompt."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import guardrails as gd\n",
    "\n",
    "from rich import print"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "guard = gd.Guard.for_pydantic(output_class=Orders)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Step 3: Wrap the LLM API call with `Guard`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/dtam/dev/guardrails/guardrails/validator_service/__init__.py:85: UserWarning: Could not obtain an event loop. Falling back to synchronous validation.\n",
      "  warnings.warn(\n"
     ]
    }
   ],
   "source": [
    "# Add your OPENAI_API_KEY as an environment variable if it's not already set\n",
    "# import os\n",
    "# os.environ[\"OPENAI_API_KEY\"] = \"YOUR_API_KEY\"\n",
    "\n",
    "res = guard(\n",
    "    model=\"gpt-4o\",\n",
    "    messages=[{\"role\": \"user\", \"content\": prompt}],\n",
    "    max_tokens=2048,\n",
    "    temperature=0,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `Guard` object compiles the output schema and adds it to the prompt. We can see the final prompt below:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "Generate a dataset of fake user orders. Each row of the dataset should be valid.\n",
       "\n",
       "\n",
       "Given below is XML that describes the information to extract from this document and the tags to extract it into.\n",
       "\n",
       "<span style=\"font-weight: bold\">&lt;</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff; font-weight: bold\">output</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  &lt;list </span><span style=\"color: #808000; text-decoration-color: #808000\">description</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"Generate a list of user, and how many orders they have placed in the past.\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span>\n",
       "<span style=\"color: #808000; text-decoration-color: #808000\">format</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"guardrails/valid_length: 10 10\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"user_orders\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">required</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"true\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;object </span><span style=\"color: #808000; text-decoration-color: #808000\">format</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"guardrails/valid_length: 10 10\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">required</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"true\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">      &lt;string </span><span style=\"color: #808000; text-decoration-color: #808000\">description</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"The user's id.\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">required</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"true\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">string</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">      &lt;string </span><span style=\"color: #808000; text-decoration-color: #808000\">description</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"The user's first name and last name\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">format</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"guardrails/two_words\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span>\n",
       "<span style=\"color: #808000; text-decoration-color: #808000\">required</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"true\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">string</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">      &lt;integer </span><span style=\"color: #808000; text-decoration-color: #808000\">description</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"The number of orders the user has placed\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">format</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"guardrails/valid_range: 0 50\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span>\n",
       "<span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">required</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"true\"</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">integer</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">    &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">object</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">  &lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">list</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">output</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;</span>\n",
       "\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">ONLY return a valid JSON object </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">no other text is necessary</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\">, where the key of the field in JSON is the `name` </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">attribute of the corresponding XML, and the value is of the type specified by the corresponding XML's tag. The JSON</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">MUST conform to the XML format, including any types and format requests e.g. requests for lists, objects and </span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">specific types. Be correct and concise. If you are unsure anywhere, enter `null`.</span>\n",
       "\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">Here are examples of simple </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">(</span><span style=\"color: #000000; text-decoration-color: #000000\">XML, JSON</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">)</span><span style=\"color: #000000; text-decoration-color: #000000\"> pairs that show the expected behavior:</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">- `&lt;string </span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">'foo'</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">format</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">'two-words lower-case'</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;` =&gt; `</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'foo'</span><span style=\"color: #000000; text-decoration-color: #000000\">: </span><span style=\"color: #008000; text-decoration-color: #008000\">'example one'</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">}</span><span style=\"color: #000000; text-decoration-color: #000000\">`</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">- `&lt;list </span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">'bar'</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;&lt;string </span><span style=\"color: #808000; text-decoration-color: #808000\">format</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">'upper-case'</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">list</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;` =&gt; `</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">\"bar\"</span><span style=\"color: #000000; text-decoration-color: #000000\">: </span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">[</span><span style=\"color: #008000; text-decoration-color: #008000\">'STRING ONE'</span><span style=\"color: #000000; text-decoration-color: #000000\">, </span><span style=\"color: #008000; text-decoration-color: #008000\">'STRING TWO'</span><span style=\"color: #000000; text-decoration-color: #000000\">, etc.</span><span style=\"color: #000000; text-decoration-color: #000000; font-weight: bold\">]}</span><span style=\"color: #000000; text-decoration-color: #000000\">`</span>\n",
       "<span style=\"color: #000000; text-decoration-color: #000000\">- `&lt;object </span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">'baz'</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;&lt;string </span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"foo\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">format</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"capitalize two-words\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;&lt;integer </span><span style=\"color: #808000; text-decoration-color: #808000\">name</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"index\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span><span style=\"color: #808000; text-decoration-color: #808000\">format</span><span style=\"color: #000000; text-decoration-color: #000000\">=</span><span style=\"color: #008000; text-decoration-color: #008000\">\"1-indexed\"</span><span style=\"color: #000000; text-decoration-color: #000000\"> </span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;&lt;</span><span style=\"color: #800080; text-decoration-color: #800080\">/</span><span style=\"color: #ff00ff; text-decoration-color: #ff00ff\">object</span><span style=\"color: #000000; text-decoration-color: #000000\">&gt;` =</span><span style=\"font-weight: bold\">&gt;</span> `<span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'baz'</span>: <span style=\"font-weight: bold\">{</span><span style=\"color: #008000; text-decoration-color: #008000\">'foo'</span>: <span style=\"color: #008000; text-decoration-color: #008000\">'Some String'</span>, <span style=\"color: #008000; text-decoration-color: #008000\">'index'</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"font-weight: bold\">}}</span>`\n",
       "\n",
       "\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n",
       "Generate a dataset of fake user orders. Each row of the dataset should be valid.\n",
       "\n",
       "\n",
       "Given below is XML that describes the information to extract from this document and the tags to extract it into.\n",
       "\n",
       "\u001b[1m<\u001b[0m\u001b[1;95moutput\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m  <list \u001b[0m\u001b[33mdescription\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"Generate\u001b[0m\u001b[32m a list of user, and how many orders they have placed in the past.\"\u001b[0m\u001b[39m \u001b[0m\n",
       "\u001b[33mformat\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"guardrails\u001b[0m\u001b[32m/valid_length: 10 10\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"user_orders\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mrequired\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"true\"\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <object \u001b[0m\u001b[33mformat\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"guardrails\u001b[0m\u001b[32m/valid_length: 10 10\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mrequired\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"true\"\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m      <string \u001b[0m\u001b[33mdescription\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"The\u001b[0m\u001b[32m user's id.\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"user_id\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mrequired\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"true\"\u001b[0m\u001b[39m><\u001b[0m\u001b[35m/\u001b[0m\u001b[95mstring\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m      <string \u001b[0m\u001b[33mdescription\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"The\u001b[0m\u001b[32m user's first name and last name\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mformat\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"guardrails\u001b[0m\u001b[32m/two_words\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"user_name\"\u001b[0m\u001b[39m \u001b[0m\n",
       "\u001b[33mrequired\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"true\"\u001b[0m\u001b[39m><\u001b[0m\u001b[35m/\u001b[0m\u001b[95mstring\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m      <integer \u001b[0m\u001b[33mdescription\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"The\u001b[0m\u001b[32m number of orders the user has placed\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mformat\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"guardrails\u001b[0m\u001b[32m/valid_range: 0 50\"\u001b[0m\u001b[39m \u001b[0m\n",
       "\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"num_orders\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mrequired\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"true\"\u001b[0m\u001b[39m><\u001b[0m\u001b[35m/\u001b[0m\u001b[95minteger\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m    <\u001b[0m\u001b[35m/\u001b[0m\u001b[95mobject\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m  <\u001b[0m\u001b[35m/\u001b[0m\u001b[95mlist\u001b[0m\u001b[39m>\u001b[0m\n",
       "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95moutput\u001b[0m\u001b[39m>\u001b[0m\n",
       "\n",
       "\u001b[39mONLY return a valid JSON object \u001b[0m\u001b[1;39m(\u001b[0m\u001b[39mno other text is necessary\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m, where the key of the field in JSON is the `name` \u001b[0m\n",
       "\u001b[39mattribute of the corresponding XML, and the value is of the type specified by the corresponding XML's tag. The JSON\u001b[0m\n",
       "\u001b[39mMUST conform to the XML format, including any types and format requests e.g. requests for lists, objects and \u001b[0m\n",
       "\u001b[39mspecific types. Be correct and concise. If you are unsure anywhere, enter `null`.\u001b[0m\n",
       "\n",
       "\u001b[39mHere are examples of simple \u001b[0m\u001b[1;39m(\u001b[0m\u001b[39mXML, JSON\u001b[0m\u001b[1;39m)\u001b[0m\u001b[39m pairs that show the expected behavior:\u001b[0m\n",
       "\u001b[39m- `<string \u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m'foo'\u001b[0m\u001b[39m \u001b[0m\u001b[33mformat\u001b[0m\u001b[39m=\u001b[0m\u001b[32m'two-words lower-case'\u001b[0m\u001b[39m \u001b[0m\u001b[35m/\u001b[0m\u001b[39m>` => `\u001b[0m\u001b[1;39m{\u001b[0m\u001b[32m'foo'\u001b[0m\u001b[39m: \u001b[0m\u001b[32m'example one'\u001b[0m\u001b[1;39m}\u001b[0m\u001b[39m`\u001b[0m\n",
       "\u001b[39m- `<list \u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m'bar'\u001b[0m\u001b[39m><string \u001b[0m\u001b[33mformat\u001b[0m\u001b[39m=\u001b[0m\u001b[32m'upper-case'\u001b[0m\u001b[39m \u001b[0m\u001b[35m/\u001b[0m\u001b[39m><\u001b[0m\u001b[35m/\u001b[0m\u001b[95mlist\u001b[0m\u001b[39m>` => `\u001b[0m\u001b[1;39m{\u001b[0m\u001b[32m\"bar\"\u001b[0m\u001b[39m: \u001b[0m\u001b[1;39m[\u001b[0m\u001b[32m'STRING ONE'\u001b[0m\u001b[39m, \u001b[0m\u001b[32m'STRING TWO'\u001b[0m\u001b[39m, etc.\u001b[0m\u001b[1;39m]\u001b[0m\u001b[1;39m}\u001b[0m\u001b[39m`\u001b[0m\n",
       "\u001b[39m- `<object \u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m'baz'\u001b[0m\u001b[39m><string \u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"foo\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mformat\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"capitalize\u001b[0m\u001b[32m two-words\"\u001b[0m\u001b[39m \u001b[0m\u001b[35m/\u001b[0m\u001b[39m><integer \u001b[0m\u001b[33mname\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"index\"\u001b[0m\u001b[39m \u001b[0m\u001b[33mformat\u001b[0m\u001b[39m=\u001b[0m\u001b[32m\"1\u001b[0m\u001b[32m-indexed\"\u001b[0m\u001b[39m \u001b[0m\n",
       "\u001b[35m/\u001b[0m\u001b[39m><\u001b[0m\u001b[35m/\u001b[0m\u001b[95mobject\u001b[0m\u001b[39m>` =\u001b[0m\u001b[1m>\u001b[0m `\u001b[1m{\u001b[0m\u001b[32m'baz'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'foo'\u001b[0m: \u001b[32m'Some String'\u001b[0m, \u001b[32m'index'\u001b[0m: \u001b[1;36m1\u001b[0m\u001b[1m}\u001b[0m\u001b[1m}\u001b[0m`\n",
       "\n",
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(guard.history.last.iterations.last.inputs.messages[0][\"content\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">```json\n",
       "<span style=\"font-weight: bold\">{</span>\n",
       "  <span style=\"color: #008000; text-decoration-color: #008000\">\"user_orders\"</span>: <span style=\"font-weight: bold\">[</span>\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U001\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"John Doe\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">12</span>\n",
       "    <span style=\"font-weight: bold\">}</span>,\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U002\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Jane Smith\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">8</span>\n",
       "    <span style=\"font-weight: bold\">}</span>,\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U003\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Alice Johnson\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">25</span>\n",
       "    <span style=\"font-weight: bold\">}</span>,\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U004\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Bob Brown\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">15</span>\n",
       "    <span style=\"font-weight: bold\">}</span>,\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U005\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Charlie Davis\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">30</span>\n",
       "    <span style=\"font-weight: bold\">}</span>,\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U006\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Emily White\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span>\n",
       "    <span style=\"font-weight: bold\">}</span>,\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U007\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Frank Harris\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">20</span>\n",
       "    <span style=\"font-weight: bold\">}</span>,\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U008\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Grace Lee\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">18</span>\n",
       "    <span style=\"font-weight: bold\">}</span>,\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U009\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Henry Clark\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">22</span>\n",
       "    <span style=\"font-weight: bold\">}</span>,\n",
       "    <span style=\"font-weight: bold\">{</span>\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_id\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"U010\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"user_name\"</span>: <span style=\"color: #008000; text-decoration-color: #008000\">\"Ivy Walker\"</span>,\n",
       "      <span style=\"color: #008000; text-decoration-color: #008000\">\"num_orders\"</span>: <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">10</span>\n",
       "    <span style=\"font-weight: bold\">}</span>\n",
       "  <span style=\"font-weight: bold\">]</span>\n",
       "<span style=\"font-weight: bold\">}</span>\n",
       "```\n",
       "</pre>\n"
      ],
      "text/plain": [
       "```json\n",
       "\u001b[1m{\u001b[0m\n",
       "  \u001b[32m\"user_orders\"\u001b[0m: \u001b[1m[\u001b[0m\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U001\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"John Doe\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m12\u001b[0m\n",
       "    \u001b[1m}\u001b[0m,\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U002\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"Jane Smith\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m8\u001b[0m\n",
       "    \u001b[1m}\u001b[0m,\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U003\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"Alice Johnson\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m25\u001b[0m\n",
       "    \u001b[1m}\u001b[0m,\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U004\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"Bob Brown\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m15\u001b[0m\n",
       "    \u001b[1m}\u001b[0m,\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U005\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"Charlie Davis\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m30\u001b[0m\n",
       "    \u001b[1m}\u001b[0m,\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U006\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"Emily White\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m5\u001b[0m\n",
       "    \u001b[1m}\u001b[0m,\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U007\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"Frank Harris\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m20\u001b[0m\n",
       "    \u001b[1m}\u001b[0m,\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U008\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"Grace Lee\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m18\u001b[0m\n",
       "    \u001b[1m}\u001b[0m,\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U009\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"Henry Clark\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m22\u001b[0m\n",
       "    \u001b[1m}\u001b[0m,\n",
       "    \u001b[1m{\u001b[0m\n",
       "      \u001b[32m\"user_id\"\u001b[0m: \u001b[32m\"U010\"\u001b[0m,\n",
       "      \u001b[32m\"user_name\"\u001b[0m: \u001b[32m\"Ivy Walker\"\u001b[0m,\n",
       "      \u001b[32m\"num_orders\"\u001b[0m: \u001b[1;36m10\u001b[0m\n",
       "    \u001b[1m}\u001b[0m\n",
       "  \u001b[1m]\u001b[0m\n",
       "\u001b[1m}\u001b[0m\n",
       "```\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "{'user_orders': [{'user_id': 'U001',\n",
       "   'user_name': 'John Doe',\n",
       "   'num_orders': 12},\n",
       "  {'user_id': 'U002', 'user_name': 'Jane Smith', 'num_orders': 8},\n",
       "  {'user_id': 'U003', 'user_name': 'Alice Johnson', 'num_orders': 25},\n",
       "  {'user_id': 'U004', 'user_name': 'Bob Brown', 'num_orders': 15},\n",
       "  {'user_id': 'U005', 'user_name': 'Charlie Davis', 'num_orders': 30},\n",
       "  {'user_id': 'U006', 'user_name': 'Emily White', 'num_orders': 5},\n",
       "  {'user_id': 'U007', 'user_name': 'Frank Harris', 'num_orders': 20},\n",
       "  {'user_id': 'U008', 'user_name': 'Grace Lee', 'num_orders': 18},\n",
       "  {'user_id': 'U009', 'user_name': 'Henry Clark', 'num_orders': 22},\n",
       "  {'user_id': 'U010', 'user_name': 'Ivy Walker', 'num_orders': 10}]}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(res.raw_llm_output)\n",
    "res.validated_output"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Running the cell above returns:\n",
    "1. The raw LLM text output as a single string.\n",
    "2. A dictionary where the key `user_orders` key contains a list of dictionaries, where each dictionary represents a row in the dataframe."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">Logs\n",
       "└── ╭────────────────────────────────────────────────── Step 0 ───────────────────────────────────────────────────╮\n",
       "    │ <span style=\"background-color: #e7dfeb\">╭─────────────────────────────────────────────── Messages ────────────────────────────────────────────────╮</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ ┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ ┃</span><span style=\"background-color: #e7dfeb; font-weight: bold\"> Role </span><span style=\"background-color: #e7dfeb\">┃</span><span style=\"background-color: #e7dfeb; font-weight: bold\"> Content                                                                                      </span><span style=\"background-color: #e7dfeb\">┃ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ ┡━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │ user │                                                                                              │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ Generate a dataset of fake user orders. Each row of the dataset should be valid.             │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │                                                                                              │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │                                                                                              │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ Given below is XML that describes the information to extract from this document and the tags │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ to extract it into.                                                                          │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │                                                                                              │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ &lt;output&gt;                                                                                     │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │   &lt;list description=\"Generate a list of user, and how many orders they have placed in the    │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ past.\" format=\"guardrails/valid_length: 10 10\" name=\"user_orders\" required=\"true\"&gt;           │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │     &lt;object format=\"guardrails/valid_length: 10 10\" required=\"true\"&gt;                         │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │       &lt;string description=\"The user's id.\" name=\"user_id\" required=\"true\"&gt;&lt;/string&gt;          │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │       &lt;string description=\"The user's first name and last name\"                              │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ format=\"guardrails/two_words\" name=\"user_name\" required=\"true\"&gt;&lt;/string&gt;                     │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │       &lt;integer description=\"The number of orders the user has placed\"                        │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ format=\"guardrails/valid_range: 0 50\" name=\"num_orders\" required=\"true\"&gt;&lt;/integer&gt;           │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │     &lt;/object&gt;                                                                                │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │   &lt;/list&gt;                                                                                    │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ &lt;/output&gt;                                                                                    │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │                                                                                              │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ ONLY return a valid JSON object (no other text is necessary), where the key of the field in  │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ JSON is the `name` attribute of the corresponding XML, and the value is of the type          │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ specified by the corresponding XML's tag. The JSON MUST conform to the XML format, including │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ any types and format requests e.g. requests for lists, objects and specific types. Be        │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ correct and concise. If you are unsure anywhere, enter `null`.                               │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │                                                                                              │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ Here are examples of simple (XML, JSON) pairs that show the expected behavior:               │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ - `&lt;string name='foo' format='two-words lower-case' /&gt;` =&gt; `{'foo': 'example one'}`          │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ - `&lt;list name='bar'&gt;&lt;string format='upper-case' /&gt;&lt;/list&gt;` =&gt; `{\"bar\": ['STRING ONE',        │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ 'STRING TWO', etc.]}`                                                                        │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ - `&lt;object name='baz'&gt;&lt;string name=\"foo\" format=\"capitalize two-words\" /&gt;&lt;integer            │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ name=\"index\" format=\"1-indexed\" /&gt;&lt;/object&gt;` =&gt; `{'baz': {'foo': 'Some String', 'index':     │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │ 1}}`                                                                                         │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │                                                                                              │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ │      │                                                                                              │ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">│ └──────┴──────────────────────────────────────────────────────────────────────────────────────────────┘ │</span> │\n",
       "    │ <span style=\"background-color: #e7dfeb\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│ ```json                                                                                                 │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│ {                                                                                                       │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│   \"user_orders\": [                                                                                      │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U001\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"John Doe\",                                                                          │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 12                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     },                                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U002\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"Jane Smith\",                                                                        │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 8                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     },                                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U003\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"Alice Johnson\",                                                                     │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 25                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     },                                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U004\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"Bob Brown\",                                                                         │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 15                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     },                                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U005\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"Charlie Davis\",                                                                     │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 30                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     },                                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U006\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"Emily White\",                                                                       │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 5                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     },                                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U007\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"Frank Harris\",                                                                      │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 20                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     },                                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U008\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"Grace Lee\",                                                                         │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 18                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     },                                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U009\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"Henry Clark\",                                                                       │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 22                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     },                                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     {                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_id\": \"U010\",                                                                                │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"user_name\": \"Ivy Walker\",                                                                        │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│       \"num_orders\": 10                                                                                  │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│     }                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│   ]                                                                                                     │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│ }                                                                                                       │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">│ ```                                                                                                     │</span> │\n",
       "    │ <span style=\"background-color: #f5f5dc\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">╭─────────────────────────────────────────── Validated Output ────────────────────────────────────────────╮</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│ {                                                                                                       │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│     'user_orders': [                                                                                    │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U001', 'user_name': 'John Doe', 'num_orders': 12},                                 │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U002', 'user_name': 'Jane Smith', 'num_orders': 8},                                │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U003', 'user_name': 'Alice Johnson', 'num_orders': 25},                            │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U004', 'user_name': 'Bob Brown', 'num_orders': 15},                                │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U005', 'user_name': 'Charlie Davis', 'num_orders': 30},                            │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U006', 'user_name': 'Emily White', 'num_orders': 5},                               │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U007', 'user_name': 'Frank Harris', 'num_orders': 20},                             │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U008', 'user_name': 'Grace Lee', 'num_orders': 18},                                │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U009', 'user_name': 'Henry Clark', 'num_orders': 22},                              │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│         {'user_id': 'U010', 'user_name': 'Ivy Walker', 'num_orders': 10}                                │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│     ]                                                                                                   │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">│ }                                                                                                       │</span> │\n",
       "    │ <span style=\"background-color: #f0fff0\">╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯</span> │\n",
       "    ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n",
       "</pre>\n"
      ],
      "text/plain": [
       "Logs\n",
       "└── ╭────────────────────────────────────────────────── Step 0 ───────────────────────────────────────────────────╮\n",
       "    │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m──────────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Messages \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent                                                                                     \u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235muser\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m                                                                                            \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mGenerate a dataset of fake user orders. Each row of the dataset should be valid.            \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m                                                                                            \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m                                                                                            \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mGiven below is XML that describes the information to extract from this document and the tags\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mto extract it into.                                                                         \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m                                                                                            \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m<output>                                                                                    \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m  <list description=\"Generate a list of user, and how many orders they have placed in the   \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mpast.\" format=\"guardrails/valid_length: 10 10\" name=\"user_orders\" required=\"true\">          \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m    <object format=\"guardrails/valid_length: 10 10\" required=\"true\">                        \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m      <string description=\"The user's id.\" name=\"user_id\" required=\"true\"></string>         \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m      <string description=\"The user's first name and last name\"                             \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mformat=\"guardrails/two_words\" name=\"user_name\" required=\"true\"></string>                    \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m      <integer description=\"The number of orders the user has placed\"                       \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mformat=\"guardrails/valid_range: 0 50\" name=\"num_orders\" required=\"true\"></integer>          \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m    </object>                                                                               \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m  </list>                                                                                   \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m</output>                                                                                   \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m                                                                                            \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mONLY return a valid JSON object (no other text is necessary), where the key of the field in \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mJSON is the `name` attribute of the corresponding XML, and the value is of the type         \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mspecified by the corresponding XML's tag. The JSON MUST conform to the XML format, including\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235many types and format requests e.g. requests for lists, objects and specific types. Be       \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mcorrect and concise. If you are unsure anywhere, enter `null`.                              \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m                                                                                            \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mHere are examples of simple (XML, JSON) pairs that show the expected behavior:              \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m- `<string name='foo' format='two-words lower-case' />` => `{'foo': 'example one'}`         \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m- `<list name='bar'><string format='upper-case' /></list>` => `{\"bar\": ['STRING ONE',       \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m'STRING TWO', etc.]}`                                                                       \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m- `<object name='baz'><string name=\"foo\" format=\"capitalize two-words\" /><integer           \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mname=\"index\" format=\"1-indexed\" /></object>` => `{'baz': {'foo': 'Some String', 'index':    \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m1}}`                                                                                        \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m                                                                                            \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m      \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m                                                                                            \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴──────────────────────────────────────────────────────────────────────────────────────────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
       "    │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m```json\u001b[0m\u001b[48;2;245;245;220m                                                                                                \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\u001b[0m\u001b[48;2;245;245;220m                                                                                                      \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m  \"user_orders\": [\u001b[0m\u001b[48;2;245;245;220m                                                                                     \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U001\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"John Doe\",\u001b[0m\u001b[48;2;245;245;220m                                                                         \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 12\u001b[0m\u001b[48;2;245;245;220m                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    },\u001b[0m\u001b[48;2;245;245;220m                                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U002\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"Jane Smith\",\u001b[0m\u001b[48;2;245;245;220m                                                                       \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 8\u001b[0m\u001b[48;2;245;245;220m                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    },\u001b[0m\u001b[48;2;245;245;220m                                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U003\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"Alice Johnson\",\u001b[0m\u001b[48;2;245;245;220m                                                                    \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 25\u001b[0m\u001b[48;2;245;245;220m                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    },\u001b[0m\u001b[48;2;245;245;220m                                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U004\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"Bob Brown\",\u001b[0m\u001b[48;2;245;245;220m                                                                        \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 15\u001b[0m\u001b[48;2;245;245;220m                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    },\u001b[0m\u001b[48;2;245;245;220m                                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U005\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"Charlie Davis\",\u001b[0m\u001b[48;2;245;245;220m                                                                    \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 30\u001b[0m\u001b[48;2;245;245;220m                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    },\u001b[0m\u001b[48;2;245;245;220m                                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U006\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"Emily White\",\u001b[0m\u001b[48;2;245;245;220m                                                                      \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 5\u001b[0m\u001b[48;2;245;245;220m                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    },\u001b[0m\u001b[48;2;245;245;220m                                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U007\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"Frank Harris\",\u001b[0m\u001b[48;2;245;245;220m                                                                     \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 20\u001b[0m\u001b[48;2;245;245;220m                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    },\u001b[0m\u001b[48;2;245;245;220m                                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U008\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"Grace Lee\",\u001b[0m\u001b[48;2;245;245;220m                                                                        \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 18\u001b[0m\u001b[48;2;245;245;220m                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    },\u001b[0m\u001b[48;2;245;245;220m                                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U009\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"Henry Clark\",\u001b[0m\u001b[48;2;245;245;220m                                                                      \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 22\u001b[0m\u001b[48;2;245;245;220m                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    },\u001b[0m\u001b[48;2;245;245;220m                                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    {\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_id\": \"U010\",\u001b[0m\u001b[48;2;245;245;220m                                                                               \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"user_name\": \"Ivy Walker\",\u001b[0m\u001b[48;2;245;245;220m                                                                       \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m      \"num_orders\": 10\u001b[0m\u001b[48;2;245;245;220m                                                                                 \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m    }\u001b[0m\u001b[48;2;245;245;220m                                                                                                  \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m  ]\u001b[0m\u001b[48;2;245;245;220m                                                                                                    \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m}\u001b[0m\u001b[48;2;245;245;220m                                                                                                      \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m```\u001b[0m\u001b[48;2;245;245;220m                                                                                                    \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
       "    │ \u001b[48;2;245;245;220m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m╭─\u001b[0m\u001b[48;2;240;255;240m──────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m Validated Output \u001b[0m\u001b[48;2;240;255;240m───────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m─╮\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m{\u001b[0m\u001b[48;2;240;255;240m                                                                                                      \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m    'user_orders': [\u001b[0m\u001b[48;2;240;255;240m                                                                                   \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U001', 'user_name': 'John Doe', 'num_orders': 12},\u001b[0m\u001b[48;2;240;255;240m                                \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U002', 'user_name': 'Jane Smith', 'num_orders': 8},\u001b[0m\u001b[48;2;240;255;240m                               \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U003', 'user_name': 'Alice Johnson', 'num_orders': 25},\u001b[0m\u001b[48;2;240;255;240m                           \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U004', 'user_name': 'Bob Brown', 'num_orders': 15},\u001b[0m\u001b[48;2;240;255;240m                               \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U005', 'user_name': 'Charlie Davis', 'num_orders': 30},\u001b[0m\u001b[48;2;240;255;240m                           \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U006', 'user_name': 'Emily White', 'num_orders': 5},\u001b[0m\u001b[48;2;240;255;240m                              \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U007', 'user_name': 'Frank Harris', 'num_orders': 20},\u001b[0m\u001b[48;2;240;255;240m                            \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U008', 'user_name': 'Grace Lee', 'num_orders': 18},\u001b[0m\u001b[48;2;240;255;240m                               \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U009', 'user_name': 'Henry Clark', 'num_orders': 22},\u001b[0m\u001b[48;2;240;255;240m                             \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m        {'user_id': 'U010', 'user_name': 'Ivy Walker', 'num_orders': 10}\u001b[0m\u001b[48;2;240;255;240m                               \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m    ]\u001b[0m\u001b[48;2;240;255;240m                                                                                                  \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m}\u001b[0m\u001b[48;2;240;255;240m                                                                                                      \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n",
       "    │ \u001b[48;2;240;255;240m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n",
       "    ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(guard.history.last.tree)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "litellm",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
